package com.block.account.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Getter
public enum ActionTypeEnum {

    BD("BD", "补单"),
    CZ("CZ", "充值"),
    TK("TK", "退款"),
    XH("XH", "日消耗"),

//    TO("TO", "划出"),
//    TI("TI", "划入"),

    ADJUST("ADJUST", "调账"),
    CHANNEL_PAYOUT("CHANNEL_PAYOUT", "采量支出"),
    COMPANY_PAYOUT("COMPANY_PAYOUT", "公司运营"),
    STAFF_SALARY("STAFF_SALARY", "员工工资"),
    STAFF_PERCENT("STAFF_PERCENT", "员工提成"),
    AGENT_REBATE("AGENT_REBATE", "代理返点"),

    ;

    public static List<String> changeAmountList = new ArrayList<>();
    public static List<String> mainChangeAmountList = new ArrayList<>();
    static {
        changeAmountList.add(TK.getValue());
        changeAmountList.add(XH.getValue());

        changeAmountList.add(ADJUST.getValue());// 转出

        changeAmountList.add(CHANNEL_PAYOUT.getValue());// 转出
        changeAmountList.add(COMPANY_PAYOUT.getValue());// 转出
        changeAmountList.add(STAFF_SALARY.getValue());// 转出
        changeAmountList.add(STAFF_PERCENT.getValue());// 转出
        changeAmountList.add(AGENT_REBATE.getValue());// 转出

        mainChangeAmountList.add(TK.getValue());// 转出
    }


    String value;
    String name;

    ActionTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    /**
     * 根据操作类型获取真实的入账金额
     * @param actionType
     * @param amount
     * @return
     */
    public static BigDecimal getRealAmountByActionType(String actionType, BigDecimal amount){
        if (changeAmountList.contains(actionType)){
            // 金额要变负数
            return BigDecimal.ZERO.subtract(amount);
        }
        return amount;
    }

    public static BigDecimal getMainRealAmountByActionType(String actionType, BigDecimal amount){
        if (mainChangeAmountList.contains(actionType)){
            // 金额要变负数
            return BigDecimal.ZERO.subtract(amount);
        }
        return amount;
    }

}
